package com.dao;

import com.entity.Users;
import org.apache.ibatis.annotations.*;
import java.util.List;
import java.util.Map;

public interface UsersMapper {

    @Select("select * from users")
    public List<Users> getAllUsers();

    @Select("select * from users where uid=#{uid}")
    public Map<String,Object> geUserByUidReturnMap(Integer uid);

    @Select("select * from users where uid=#{uid}")
    public Users getUserByUid(Integer uid);

    @Insert("insert into users (username,password,mobile,email,type) values (#{username},#{password},#{mobile},#{email},#{type}) ")
    @Options(useGeneratedKeys=true,keyProperty = "uid", keyColumn = "uid")
    public int addUser(Users u);

    @Update("update users set username = #{username},password=#{password},mobile=#{mobile},email=#{email},type=#{type} where uid = #{uid}")
    public int updateUser(Users u);

    @Delete("delete from users where uid = #{uid}")
    public int deleteUser(Integer uid);

    @Select("select * from users where username=#{uname} and password=#{upass}")
    public List<Users> login(@Param("uname") String username,@Param("upass") String password);

}
